//
//  Status.m
//  MYChatting
//
//  Created by mac on 16/8/19.
//  Copyright © 2016年 lhf. All rights reserved.
//

#import "Status.h"
#import "User.h"

@implementation Status

//- (void)setId:(int64_t)id{
//    _id = id;
//    
//    _ids = [NSString stringWithFormat:@"%lld",id];
//}

//- (void)setPic_urls:(NSArray *)pic_urls{
//    _pic_urls = pic_urls;
//    NSLog(@"kkkkkk----%@",_pic_urls);
//    for (NSDictionary *picDict in _pic_urls) {
//        
//        NSString *picString = picDict[@"thumbnail_pic"];
//        [_pic_strs addObject:picString];
//        
//        NSLog(@"内-----%@",_pic_strs);
//    }
//    NSLog(@"外-----%@",_pic_strs);
//}

- (instancetype)initWithDict:(NSDictionary *)dict
{
   
    self = [super init];
    if (self) {
       // _ids = [NSString stringWithFormat:@"%@",dict[@"id"]];
//        self.created_at = dict[@"created_at"];
//         self.id = dict[@"id"];
//        self.source = dict[@"source"];
//        self.text = dict[@"text"];
//        self.pic_urls = dict[@"pic_urls"];
//        self.user = [User userWithDict:dict[@"user"]];
       // self.retweeted_status = [Status statusWithDict:dict[@"retweeted_status"]];
        //self.pic_strs = dict[@"pic_strs"];
        [self setValuesForKeysWithDictionary:dict];
    }
   
    return self;
}


+ (instancetype)statusWithDict:(NSDictionary *)dict{
    return [[self alloc] initWithDict:dict];
}



- (void)setValue:(nullable id)value forKey:(nonnull NSString *)key{
    if ([key  isEqual: @"user"]) {
        self.user = [User userWithDict:value];
        return;
    }
    
    if ([key isEqualToString:@"retweeted_status"]) {
        self.retweeted_status = [Status statusWithDict:value];
        return;
    }
    
    [super setValue:value forKey:key];
}

- (void)setValue:(nullable id)value forUndefinedKey:(nonnull NSString *)key{
    
}


//+ (NSArray *)properties{
//    return @[@"created_at",@"id",@"text",@"source",@"user",@"pic_urls"];
//}
//
//
//+ (instancetype)statusWithDict:(NSDictionary *)dict{
//    id obj = [[self alloc] init];
//    for (NSString *property in [self properties]) {
//        if ([property isEqualToString:@"user"]) {
//             //[User userWithDict:dict[property]];
//            if (dict[property] != nil) {
//                [obj setValue:[User userWithDict:dict[property]] forKeyPath:@"user"];
//                
//            }
//        
//        }else{
//            if (dict[property] != nil) {
//                [obj setValue:dict[property] forKey:property];
//            }
//            
//        }
//    }
//    return obj;
//}



@end
